/*
 * NyRestaurantPaymentSystemView.java
 */

package nyrestaurantpaymentsystem;

import org.jdesktop.application.Action;
import org.jdesktop.application.ResourceMap;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.TaskMonitor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Timer;
import javax.swing.Icon;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextArea;

/**
 * The application's main frame.
 */
public class NyRestaurantPaymentSystemView extends FrameView {
    
        private Restaurant restaurant;

    public NyRestaurantPaymentSystemView(SingleFrameApplication app) {
        super(app);
        assert false;
        initComponents();

        // status bar initialization - message timeout, idle icon and busy animation, etc
        ResourceMap resourceMap = getResourceMap();
        int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
        messageTimer = new Timer(messageTimeout, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                statusMessageLabel.setText("");
            }
        });
        messageTimer.setRepeats(false);
        int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
        for (int i = 0; i < busyIcons.length; i++) {
            busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
        }
        busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
                statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
            }
        });
        idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
        statusAnimationLabel.setIcon(idleIcon);
        progressBar.setVisible(false);

        // connecting action tasks to status bar via TaskMonitor
        TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
        taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                String propertyName = evt.getPropertyName();
                if ("started".equals(propertyName)) {
                    if (!busyIconTimer.isRunning()) {
                        statusAnimationLabel.setIcon(busyIcons[0]);
                        busyIconIndex = 0;
                        busyIconTimer.start();
                    }
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(true);
                } else if ("done".equals(propertyName)) {
                    busyIconTimer.stop();
                    statusAnimationLabel.setIcon(idleIcon);
                    progressBar.setVisible(false);
                    progressBar.setValue(0);
                } else if ("message".equals(propertyName)) {
                    String text = (String)(evt.getNewValue());
                    statusMessageLabel.setText((text == null) ? "" : text);
                    messageTimer.restart();
                } else if ("progress".equals(propertyName)) {
                    int value = (Integer)(evt.getNewValue());
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(false);
                    progressBar.setValue(value);
                }
            }
        });

        JTextArea[] jTextAreaArray = { table_1_textfield, table_2_textfield, 
                                        table_3_textfield, table_4_textfield };
        
        String[] strArrayTableNames = { "table_1", "table_2", "table_3", "table_4" };
        restaurant = new Restaurant(this, strArrayTableNames.length, strArrayTableNames, jTextAreaArray);
    
    }
     private void toggleLabelVisible(JLabel jLabel)
     {
       if(jLabel.isEnabled())
       {
       jLabel.setEnabled(false);
       }
       else 
       {
           jLabel.setEnabled(true);
       }
     }
     
     private void toggleTableTimer(JLabel jLabel)
    {
        Table table = restaurant.returnTableBelongsToJLabel(jLabel);
        
        if(table.hasTimer() == true )
        {
            table.getMoneyTask().cancel();
            table.setHasTimer(false);
        }
        else
        {
           table.createAndAddMoneyTask(restaurant.getMoneyTimer());
           table.setHasTimer(true);
        }
        

    }
     
     
     
    public void updateTextField(JTextArea jta, String s)
    {
        jta.setText(s);
    }
    
    @Action
    public void showAboutBox() {
        if (aboutBox == null) {
            JFrame mainFrame = NyRestaurantPaymentSystemApp.getApplication().getMainFrame();
            aboutBox = new NyRestaurantPaymentSystemAboutBox(mainFrame);
            aboutBox.setLocationRelativeTo(mainFrame);
        }
        NyRestaurantPaymentSystemApp.getApplication().show(aboutBox);
    }
    

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        chair1_1 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        table_1 = new javax.swing.JLabel();
        chair2_1 = new javax.swing.JLabel();
        chair3_1 = new javax.swing.JLabel();
        chair4_1 = new javax.swing.JLabel();
        Restaurant_Payment_System_Label = new java.awt.Label();
        chair1_2 = new javax.swing.JLabel();
        chair2_2 = new javax.swing.JLabel();
        table_2 = new javax.swing.JLabel();
        chair3_2 = new javax.swing.JLabel();
        chair4_2 = new javax.swing.JLabel();
        chair1_3 = new javax.swing.JLabel();
        chair2_3 = new javax.swing.JLabel();
        table_3 = new javax.swing.JLabel();
        chair3_3 = new javax.swing.JLabel();
        chair4_3 = new javax.swing.JLabel();
        chair1_4 = new javax.swing.JLabel();
        chair2_4 = new javax.swing.JLabel();
        table_4 = new javax.swing.JLabel();
        chair3_4 = new javax.swing.JLabel();
        chair4_4 = new javax.swing.JLabel();
        palme = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        table_2_textfield = new javax.swing.JTextArea();
        jScrollPane2 = new javax.swing.JScrollPane();
        table_1_textfield = new javax.swing.JTextArea();
        jScrollPane3 = new javax.swing.JScrollPane();
        table_3_textfield = new javax.swing.JTextArea();
        jScrollPane4 = new javax.swing.JScrollPane();
        table_4_textfield = new javax.swing.JTextArea();
        menuBar = new javax.swing.JMenuBar();
        javax.swing.JMenu fileMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
        javax.swing.JMenu helpMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
        statusPanel = new javax.swing.JPanel();
        javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
        statusMessageLabel = new javax.swing.JLabel();
        statusAnimationLabel = new javax.swing.JLabel();
        progressBar = new javax.swing.JProgressBar();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenu2 = new javax.swing.JMenu();

        mainPanel.setName("mainPanel"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(nyrestaurantpaymentsystem.NyRestaurantPaymentSystemApp.class).getContext().getResourceMap(NyRestaurantPaymentSystemView.class);
        chair1_1.setIcon(resourceMap.getIcon("chair1_1.icon")); // NOI18N
        chair1_1.setText(resourceMap.getString("chair1_1.text")); // NOI18N
        chair1_1.setEnabled(false);
        chair1_1.setName("chair1_1"); // NOI18N

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        table_1.setIcon(resourceMap.getIcon("table_1.icon")); // NOI18N
        table_1.setText(resourceMap.getString("table_1.text")); // NOI18N
        table_1.setEnabled(false);
        table_1.setName("table_1"); // NOI18N
        table_1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                TableClick(evt);
            }
        });

        chair2_1.setIcon(resourceMap.getIcon("chair2_1.icon")); // NOI18N
        chair2_1.setText(resourceMap.getString("chair2_1.text")); // NOI18N
        chair2_1.setEnabled(false);
        chair2_1.setName("chair2_1"); // NOI18N

        chair3_1.setIcon(resourceMap.getIcon("chair3_1.icon")); // NOI18N
        chair3_1.setText(resourceMap.getString("chair3_1.text")); // NOI18N
        chair3_1.setEnabled(false);
        chair3_1.setName("chair3_1"); // NOI18N

        chair4_1.setIcon(resourceMap.getIcon("chair4_1.icon")); // NOI18N
        chair4_1.setText(resourceMap.getString("chair4_1.text")); // NOI18N
        chair4_1.setEnabled(false);
        chair4_1.setName("chair4_1"); // NOI18N

        Restaurant_Payment_System_Label.setAlignment(java.awt.Label.CENTER);
        Restaurant_Payment_System_Label.setFont(resourceMap.getFont("Restaurant_Payment_System_Label.font")); // NOI18N
        Restaurant_Payment_System_Label.setName("Restaurant_Payment_System_Label"); // NOI18N
        Restaurant_Payment_System_Label.setText(resourceMap.getString("Restaurant_Payment_System_Label.text")); // NOI18N

        chair1_2.setIcon(resourceMap.getIcon("chair1_2.icon")); // NOI18N
        chair1_2.setText(resourceMap.getString("chair1_2.text")); // NOI18N
        chair1_2.setEnabled(false);
        chair1_2.setName("chair1_2"); // NOI18N

        chair2_2.setIcon(resourceMap.getIcon("chair2_2.icon")); // NOI18N
        chair2_2.setText(resourceMap.getString("chair2_2.text")); // NOI18N
        chair2_2.setEnabled(false);
        chair2_2.setName("chair2_2"); // NOI18N

        table_2.setIcon(resourceMap.getIcon("table_2.icon")); // NOI18N
        table_2.setText(resourceMap.getString("table_2.text")); // NOI18N
        table_2.setEnabled(false);
        table_2.setName("table_2"); // NOI18N
        table_2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                table_2MouseClicked(evt);
            }
        });

        chair3_2.setIcon(resourceMap.getIcon("chair3_2.icon")); // NOI18N
        chair3_2.setText(resourceMap.getString("chair3_2.text")); // NOI18N
        chair3_2.setEnabled(false);
        chair3_2.setName("chair3_2"); // NOI18N

        chair4_2.setIcon(resourceMap.getIcon("chair4_2.icon")); // NOI18N
        chair4_2.setText(resourceMap.getString("chair4_2.text")); // NOI18N
        chair4_2.setEnabled(false);
        chair4_2.setName("chair4_2"); // NOI18N

        chair1_3.setIcon(resourceMap.getIcon("chair1_3.icon")); // NOI18N
        chair1_3.setText(resourceMap.getString("chair1_3.text")); // NOI18N
        chair1_3.setEnabled(false);
        chair1_3.setName("chair1_3"); // NOI18N

        chair2_3.setIcon(resourceMap.getIcon("chair2_3.icon")); // NOI18N
        chair2_3.setText(resourceMap.getString("chair2_3.text")); // NOI18N
        chair2_3.setEnabled(false);
        chair2_3.setName("chair2_3"); // NOI18N

        table_3.setIcon(resourceMap.getIcon("table_3.icon")); // NOI18N
        table_3.setText(resourceMap.getString("table_3.text")); // NOI18N
        table_3.setEnabled(false);
        table_3.setName("table_3"); // NOI18N
        table_3.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                table_3MouseClicked(evt);
            }
        });

        chair3_3.setIcon(resourceMap.getIcon("chair3_3.icon")); // NOI18N
        chair3_3.setText(resourceMap.getString("chair3_3.text")); // NOI18N
        chair3_3.setEnabled(false);
        chair3_3.setName("chair3_3"); // NOI18N

        chair4_3.setIcon(resourceMap.getIcon("chair4_3.icon")); // NOI18N
        chair4_3.setText(resourceMap.getString("chair4_3.text")); // NOI18N
        chair4_3.setEnabled(false);
        chair4_3.setName("chair4_3"); // NOI18N

        chair1_4.setIcon(resourceMap.getIcon("chair1_4.icon")); // NOI18N
        chair1_4.setText(resourceMap.getString("chair1_4.text")); // NOI18N
        chair1_4.setEnabled(false);
        chair1_4.setName("chair1_4"); // NOI18N

        chair2_4.setIcon(resourceMap.getIcon("chair2_4.icon")); // NOI18N
        chair2_4.setText(resourceMap.getString("chair2_4.text")); // NOI18N
        chair2_4.setEnabled(false);
        chair2_4.setName("chair2_4"); // NOI18N

        table_4.setIcon(resourceMap.getIcon("table_4.icon")); // NOI18N
        table_4.setText(resourceMap.getString("table_4.text")); // NOI18N
        table_4.setEnabled(false);
        table_4.setName("table_4"); // NOI18N
        table_4.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                table_4MouseClicked(evt);
            }
        });

        chair3_4.setIcon(resourceMap.getIcon("chair3_4.icon")); // NOI18N
        chair3_4.setText(resourceMap.getString("chair3_4.text")); // NOI18N
        chair3_4.setEnabled(false);
        chair3_4.setName("chair3_4"); // NOI18N

        chair4_4.setIcon(resourceMap.getIcon("chair4_4.icon")); // NOI18N
        chair4_4.setText(resourceMap.getString("chair4_4.text")); // NOI18N
        chair4_4.setEnabled(false);
        chair4_4.setName("chair4_4"); // NOI18N

        palme.setIcon(resourceMap.getIcon("palme.icon")); // NOI18N
        palme.setText(resourceMap.getString("palme.text")); // NOI18N
        palme.setName("palme"); // NOI18N

        jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        jScrollPane1.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
        jScrollPane1.setName("jScrollPane1"); // NOI18N

        table_2_textfield.setColumns(20);
        table_2_textfield.setRows(5);
        table_2_textfield.setName("table_2_textfield"); // NOI18N
        jScrollPane1.setViewportView(table_2_textfield);

        jScrollPane2.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        jScrollPane2.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
        jScrollPane2.setName("jScrollPane2"); // NOI18N

        table_1_textfield.setColumns(20);
        table_1_textfield.setRows(5);
        table_1_textfield.setName("table_1_textfield"); // NOI18N
        jScrollPane2.setViewportView(table_1_textfield);

        jScrollPane3.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        jScrollPane3.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
        jScrollPane3.setName("jScrollPane3"); // NOI18N

        table_3_textfield.setColumns(20);
        table_3_textfield.setRows(5);
        table_3_textfield.setName("table_3_textfield"); // NOI18N
        jScrollPane3.setViewportView(table_3_textfield);

        jScrollPane4.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        jScrollPane4.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
        jScrollPane4.setName("jScrollPane4"); // NOI18N

        table_4_textfield.setColumns(20);
        table_4_textfield.setRows(5);
        table_4_textfield.setName("table_4_textfield"); // NOI18N
        jScrollPane4.setViewportView(table_4_textfield);

        org.jdesktop.layout.GroupLayout mainPanelLayout = new org.jdesktop.layout.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(mainPanelLayout.createSequentialGroup()
                .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(mainPanelLayout.createSequentialGroup()
                        .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(mainPanelLayout.createSequentialGroup()
                                .add(20, 20, 20)
                                .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(mainPanelLayout.createSequentialGroup()
                                        .add(chair1_1)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                        .add(chair2_1))
                                    .add(table_1)
                                    .add(mainPanelLayout.createSequentialGroup()
                                        .add(chair3_1)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                        .add(chair4_1)))
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(table_2)
                                    .add(mainPanelLayout.createSequentialGroup()
                                        .add(chair3_2)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                        .add(chair4_2)
                                        .add(109, 109, 109)
                                        .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                            .add(table_3)
                                            .add(mainPanelLayout.createSequentialGroup()
                                                .add(chair3_3)
                                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                                .add(chair4_3))
                                            .add(mainPanelLayout.createSequentialGroup()
                                                .add(chair1_3)
                                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                                .add(chair2_3))
                                            .add(mainPanelLayout.createSequentialGroup()
                                                .add(10, 10, 10)
                                                .add(jScrollPane3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 59, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                                        .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                            .add(mainPanelLayout.createSequentialGroup()
                                                .add(37, 37, 37)
                                                .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                                    .add(mainPanelLayout.createSequentialGroup()
                                                        .add(chair3_4)
                                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                                        .add(chair4_4))
                                                    .add(table_4)
                                                    .add(mainPanelLayout.createSequentialGroup()
                                                        .add(chair1_4)
                                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                                        .add(chair2_4))))
                                            .add(mainPanelLayout.createSequentialGroup()
                                                .add(46, 46, 46)
                                                .add(jScrollPane4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 59, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
                                    .add(mainPanelLayout.createSequentialGroup()
                                        .add(chair1_2)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                        .add(chair2_2))))
                            .add(mainPanelLayout.createSequentialGroup()
                                .add(29, 29, 29)
                                .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 59, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .add(45, 45, 45)
                                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 59, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 76, Short.MAX_VALUE)
                        .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(mainPanelLayout.createSequentialGroup()
                                .add(150, 150, 150)
                                .add(jLabel5))
                            .add(mainPanelLayout.createSequentialGroup()
                                .add(58, 58, 58)
                                .add(palme))))
                    .add(mainPanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .add(Restaurant_Payment_System_Label, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 562, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(mainPanelLayout.createSequentialGroup()
                .add(26, 26, 26)
                .add(Restaurant_Payment_System_Label, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 38, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(mainPanelLayout.createSequentialGroup()
                        .add(105, 105, 105)
                        .add(jLabel5)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(palme))
                    .add(mainPanelLayout.createSequentialGroup()
                        .add(33, 33, 33)
                        .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(mainPanelLayout.createSequentialGroup()
                                .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                    .add(chair1_4)
                                    .add(chair2_4))
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(table_4)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                    .add(chair3_4)
                                    .add(chair4_4)))
                            .add(mainPanelLayout.createSequentialGroup()
                                .add(7, 7, 7)
                                .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                    .add(chair2_3)
                                    .add(chair1_3))
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(table_3)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                    .add(chair3_3)
                                    .add(chair4_3))))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                            .add(jScrollPane3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 28, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jScrollPane4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 28, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                    .add(mainPanelLayout.createSequentialGroup()
                        .add(32, 32, 32)
                        .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(mainPanelLayout.createSequentialGroup()
                                .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                    .add(chair1_1)
                                    .add(chair2_1))
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(table_1)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                    .add(chair3_1)
                                    .add(chair4_1)))
                            .add(mainPanelLayout.createSequentialGroup()
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                    .add(chair1_2)
                                    .add(chair2_2))
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(table_2)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(chair4_2)
                                    .add(chair3_2))))
                        .add(18, 18, 18)
                        .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 28, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 28, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(76, Short.MAX_VALUE))
        );

        Restaurant_Payment_System_Label.getAccessibleContext().setAccessibleName(resourceMap.getString("label1.AccessibleContext.accessibleName")); // NOI18N

        menuBar.setName("menuBar"); // NOI18N

        fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
        fileMenu.setName("fileMenu"); // NOI18N

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(nyrestaurantpaymentsystem.NyRestaurantPaymentSystemApp.class).getContext().getActionMap(NyRestaurantPaymentSystemView.class, this);
        exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
        exitMenuItem.setIcon(resourceMap.getIcon("exitMenuItem.icon")); // NOI18N
        exitMenuItem.setText(resourceMap.getString("exitMenuItem.text")); // NOI18N
        exitMenuItem.setName("exitMenuItem"); // NOI18N
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
        helpMenu.setName("helpMenu"); // NOI18N

        aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
        aboutMenuItem.setName("aboutMenuItem"); // NOI18N
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        statusPanel.setName("statusPanel"); // NOI18N

        statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N

        statusMessageLabel.setName("statusMessageLabel"); // NOI18N

        statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N

        progressBar.setName("progressBar"); // NOI18N

        org.jdesktop.layout.GroupLayout statusPanelLayout = new org.jdesktop.layout.GroupLayout(statusPanel);
        statusPanel.setLayout(statusPanelLayout);
        statusPanelLayout.setHorizontalGroup(
            statusPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(statusPanelSeparator, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 798, Short.MAX_VALUE)
            .add(statusPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(statusMessageLabel)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 624, Short.MAX_VALUE)
                .add(progressBar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(statusAnimationLabel)
                .addContainerGap())
        );
        statusPanelLayout.setVerticalGroup(
            statusPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(statusPanelLayout.createSequentialGroup()
                .add(statusPanelSeparator, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(statusPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(statusMessageLabel)
                    .add(statusAnimationLabel)
                    .add(progressBar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(3, 3, 3))
        );

        jMenuBar1.setName("jMenuBar1"); // NOI18N

        jMenu1.setText(resourceMap.getString("jMenu1.text")); // NOI18N
        jMenu1.setName("jMenu1"); // NOI18N
        jMenuBar1.add(jMenu1);

        jMenu2.setText(resourceMap.getString("jMenu2.text")); // NOI18N
        jMenu2.setName("jMenu2"); // NOI18N
        jMenuBar1.add(jMenu2);

        setComponent(mainPanel);
        setMenuBar(menuBar);
        setStatusBar(statusPanel);
    }// </editor-fold>//GEN-END:initComponents

    private void TableClick(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_TableClick
        // Table 1: Chairs 1-4:
        toggleLabelVisible(chair1_1);
        toggleLabelVisible(chair2_1);
        toggleLabelVisible(chair3_1);
        toggleLabelVisible(chair4_1);
        toggleLabelVisible(table_1);                                
        toggleTableTimer((JLabel)evt.getSource());
    }//GEN-LAST:event_TableClick

    private void table_2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_table_2MouseClicked
               // Table 2: Chairs 1-4:
        toggleLabelVisible(chair1_2);
        toggleLabelVisible(chair2_2);
        toggleLabelVisible(chair3_2);
        toggleLabelVisible(chair4_2);
        toggleLabelVisible(table_2);
        toggleTableTimer((JLabel)evt.getSource());

}//GEN-LAST:event_table_2MouseClicked

    private void table_3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_table_3MouseClicked
        // TODO add your handling code here:
        toggleLabelVisible(chair1_3);
        toggleLabelVisible(chair2_3);
        toggleLabelVisible(chair3_3);
        toggleLabelVisible(chair4_3);
        toggleLabelVisible(table_3);
        toggleTableTimer((JLabel)evt.getSource());
}//GEN-LAST:event_table_3MouseClicked

    private void table_4MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_table_4MouseClicked
        // TODO add your handling code here:
        toggleLabelVisible(chair1_4);
        toggleLabelVisible(chair2_4);
        toggleLabelVisible(chair3_4);
        toggleLabelVisible(chair4_4);
        toggleLabelVisible(table_4);
        toggleTableTimer((JLabel)evt.getSource());

    }//GEN-LAST:event_table_4MouseClicked

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private java.awt.Label Restaurant_Payment_System_Label;
    private javax.swing.JLabel chair1_1;
    private javax.swing.JLabel chair1_2;
    private javax.swing.JLabel chair1_3;
    private javax.swing.JLabel chair1_4;
    private javax.swing.JLabel chair2_1;
    private javax.swing.JLabel chair2_2;
    private javax.swing.JLabel chair2_3;
    private javax.swing.JLabel chair2_4;
    private javax.swing.JLabel chair3_1;
    private javax.swing.JLabel chair3_2;
    private javax.swing.JLabel chair3_3;
    private javax.swing.JLabel chair3_4;
    private javax.swing.JLabel chair4_1;
    private javax.swing.JLabel chair4_2;
    private javax.swing.JLabel chair4_3;
    private javax.swing.JLabel chair4_4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JLabel palme;
    private javax.swing.JProgressBar progressBar;
    private javax.swing.JLabel statusAnimationLabel;
    private javax.swing.JLabel statusMessageLabel;
    private javax.swing.JPanel statusPanel;
    private javax.swing.JLabel table_1;
    private volatile javax.swing.JTextArea table_1_textfield;
    private javax.swing.JLabel table_2;
    private volatile javax.swing.JTextArea table_2_textfield;
    private javax.swing.JLabel table_3;
    private volatile javax.swing.JTextArea table_3_textfield;
    private javax.swing.JLabel table_4;
    private volatile javax.swing.JTextArea table_4_textfield;
    // End of variables declaration//GEN-END:variables

    private final Timer messageTimer;
    private final Timer busyIconTimer;
    private final Icon idleIcon;
    private final Icon[] busyIcons = new Icon[15];
    private int busyIconIndex = 0;

    private JDialog aboutBox;
}
